﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="ProtoBufWorkbench.MainWindow"
        Title="Protocol Buffers Workbench" Height="350" Width="525" xmlns:my="clr-namespace:ProtoBufWorkbench" >
    <Window.DataContext>
        <my:MainWindowViewModel/>
    </Window.DataContext>
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    </Window.Resources>
    <Grid Margin="5">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="285*" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="100*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="152*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="158*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="155*" />
            </Grid.ColumnDefinitions>
            <GridSplitter Grid.Column="1" HorizontalAlignment="Center"  x:Name="gridSplitter1" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" Width="5" Margin="2,0" Grid.Row="1" />
            <GridSplitter Grid.Column="3" HorizontalAlignment="Right"  x:Name="gridSplitter2" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" Width="5" Grid.Row="1" />
            <GridSplitter Grid.Column="0" HorizontalAlignment="Right"  x:Name="gridSplitter3" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" Grid.RowSpan="1" Grid.Row="2" Height="5" ResizeDirection="Rows" />
            <TextBlock Grid.RowSpan="1" HorizontalAlignment="Center" x:Name="textBlock1" Text="Message Definition" VerticalAlignment="Center" FontWeight="Bold" Margin="0,5" />
            <TextBlock FontWeight="Bold" HorizontalAlignment="Center" x:Name="textBlock2" Text="Message (Text Format)" VerticalAlignment="Center" Grid.Column="2" Margin="0,5" />
            <TextBlock FontWeight="Bold" HorizontalAlignment="Center" x:Name="textBlock3" Text="Message (Binary Format)" VerticalAlignment="Center" Grid.Column="5" Margin="0,5" />
            <DockPanel Grid.Row="1">
            	<TextBlock TextWrapping="Wrap" DockPanel.Dock="Top" Margin="5,5,5,0"><Run Text="Root Message:"/></TextBlock>
                <ComboBox ItemsSource="{Binding AvailableMessageTypes}" SelectedItem="{Binding RootMessageName}"  VerticalAlignment="Top" DockPanel.Dock="Top" IsEditable="False" Margin="5,2,5,5" ToolTip="Indicate which message is the implicit root message in the document"/>
            	<TextBox HorizontalAlignment="Stretch" x:Name="MessageDefinitionText" Text="{Binding MessageDefinition, UpdateSourceTrigger=LostFocus}" VerticalAlignment="Stretch" AcceptsReturn="True" AcceptsTab="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"/>
            </DockPanel>
            <TextBox HorizontalAlignment="Stretch" x:Name="MessageText" Text="{Binding MessageText}" VerticalAlignment="Stretch" Grid.Column="2" Grid.Row="1" AcceptsReturn="True" AcceptsTab="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"/>
        	<StackPanel Grid.Column="3" Orientation="Vertical" d:LayoutOverrides="Height" Grid.Row="1" VerticalAlignment="Center" Margin="5,0">
        		<Button Content="&gt;" Height="28" Command="{Binding Encode}" HorizontalAlignment="Left" x:Name="button1" VerticalAlignment="Top" Width="22" ToolTip="Encode" Margin="0,0,0,5" />
        		<Button Content="&lt;" Height="28" Command="{Binding Decode}" HorizontalAlignment="Left" x:Name="button2" VerticalAlignment="Top" Width="22" ToolTip="Decode" />
        	</StackPanel>
            <TextBox HorizontalAlignment="Stretch" x:Name="ErrorMessages" Text="{Binding Path=Errors, Mode=OneWay}" VerticalAlignment="Stretch" Grid.Row="3" Grid.ColumnSpan="6" IsReadOnly="True" VerticalScrollBarVisibility="Auto" />
            <DockPanel Grid.Column="4" Grid.Row="1">
                <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Margin="5">
                    <RadioButton x:Name="HexOption" Content="Hex" Margin="5,0,0,0" IsChecked="True" ToolTip="Shows the binary-encoded message in a Hex editor"/>
                    <RadioButton x:Name="CSharpOption" Content="C#" Margin="5,0,0,0" ToolTip="Shows the binary-encoded message as a C# byte array"/>
                </StackPanel>
                <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="5">
                    <Button Content="Paste" ToolTip="Paste from Binary as Text (must start with the 0x identifier)" Command="{Binding PasteFromBinaryText}"/>
                </StackPanel>
                <Grid>
                    <my:HexEditor  HorizontalAlignment="Stretch" x:Name="MessageBinary" HexBytes="{Binding MessageBinary}" VerticalAlignment="Stretch" Visibility="{Binding ElementName=HexOption, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                    <TextBox  HorizontalAlignment="Stretch" x:Name="MessageBinaryCSharp" Text="{Binding MessageBinaryCSharp, Mode=OneWay}" VerticalAlignment="Stretch" Visibility="{Binding ElementName=CSharpOption, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}" IsReadOnly="True" TextWrapping="Wrap" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"/>
                </Grid>
            </DockPanel>
            <TextBlock Grid.RowSpan="1" HorizontalAlignment="Left" Margin="10,5,0,2" Name="textBlock4" Text="Errors" VerticalAlignment="Top" Grid.Row="2" FontWeight="Bold" Foreground="Red" />
        </Grid>
       
    </Grid>
</Window>
